package com.ruoyi.receipt.controller;

import com.ruoyi.receipt.domain.AuthAnn;
import com.ruoyi.receipt.domain.AuthEnum;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * 自定义控制器拦截
 * 这里注解@AuthAnn(authType = AuthEnum.USER_LABEL)如果加在控制器上会拦截控制器下所有的请求
 */
@RestController
@RequestMapping("/testInterceptorControl")
public class TestInterceptorControl {
    //这个测试没有注解是否会被拦截
    @RequestMapping(value = "/login",method = RequestMethod.GET)
    public Map login(){
        Map<String,String> map = new HashMap<>();
        map.put("msg","login success");
        return map;
    }
    //加上这个注解会被拦截
    @AuthAnn(authType = AuthEnum.USER_LABEL)
    @RequestMapping(value = "/queryAllProduct",method = RequestMethod.GET)
    public Map queryAllProduct(){
        Map<String,String> map = new HashMap<>();
        map.put("msg","this is all data");
        return map;
    }
}
